class Solution
{
public:
    vector<int> constructArray(int n, int k)
    {
        vector<int> answer(n, 0);
        for (int i = 0; i < n - k; ++i)
        {
            answer[i] = i + 1;
        }
        answer[n - k] = n;
        bool inc = true;
        for (int i = n - k + 1; i < n; ++i)
        {
            if (inc)
            {
                answer[i] = answer[i - 2] + 1;
            }
            else
            {
                answer[i] = answer[i - 2] - 1;
            }
            inc = !inc;
        }
        return answer;
    }
};